﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DbGenerator.Model.units.column;
using DbGenerator.Model.units.database;

namespace DbGenerator.Model.units.table
{
    public class TTableSign
    {
        #region ctors
        public TTableSign(string tableName)
        {
            _TableName = tableName;
            _TableAlias = new TAlias(String.Format("{0}_{1}"
                , _TableName.Substring(0, 2)
                , Guid.NewGuid().ToString().Replace("-", "")));
        }
        #endregion
        
        #region properties
        private string _TableName;
        public string TableName
        {
            get { return TablePrefix + _TableName; }
        }

        private TAlias _TableAlias;
        public TAlias TableAlias
        {
            get { return _TableAlias; }
        }

        private string _FirmaNo;
        public string FirmaNo
        {
            get { return _FirmaNo; }
            set { _FirmaNo = value; }
        }

        private string _DonemNo;
        public string DonemNo
        {
            get { return _DonemNo; }
            set { _DonemNo = value; }
        }

        private string TablePrefix
        {
            get
            {
                if (String.IsNullOrEmpty(_DonemNo) && String.IsNullOrEmpty(_FirmaNo))
                    return "";
                else if (String.IsNullOrEmpty(_DonemNo))
                    return String.Format("{0}_", _FirmaNo);
                else
                    return String.Format("{0}_{1}_", _FirmaNo, _DonemNo);
                //return String.Format("L_{0}_{1}_", FirmaNo, DonemNo);
            }
        }
        #endregion
    }
}
